// 柯里化模拟
function curry(fn) {
  return function curriedFn(...args) {
    // 判断实参和形参的个数
    if (args.length < fn.length) {
      return function () {
        // arguments是个伪数字
        return curriedFn(...args.concat(Array.from(arguments)))
      }
    }
    return fn(...args);// es6+展开数组
    // return fn.apply(fn, args);// 展开数组
  }
}

function getSum(a, b, c) {
  return a + b + c;
}

const curried = curry(getSum)

console.log(curried(1, 2, 3));
console.log(curried(1, 2)(3));
console.log(curried(1)(2, 3));